<?php


namespace app\api\model;


use think\Model;

class User extends Model
{
    protected $table = 'csessioninfo';
    protected $pk = 'id';

    // 一对多查询地址
    public function address()
    {
        return $this->hasMany('Address', 'user_id', 'id');
    }

    public static function getByOpenID($openid)
    {
        $user = self::where('open_id', '=', $openid)
            ->find();

        return $user;
    }
}